from selenium import webdriver
from selenium.webdriver.common.by import By

global driver


def setUpClass(name='testsh005',pwd="123456",log="登录成功"):
    chromedriver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe"
    browser = webdriver.Chrome(chromedriver)
    browser.maximize_window()
    try:
        browser.implicitly_wait(5)
        base_url = "http://118.31.116.206:8081/wnxg-merchant/login.jsp"
        browser.get(base_url)
    except:
        print(log)
        browser.execute_script('window.stop()')

    try:
        browser.find_element_by_id("username").send_keys(name)
        browser.find_element_by_id("password").send_keys(pwd)
        browser.find_element_by_class_name("login_btn").click()
    except:
        print(log)
        browser.execute_script('window.stop()')

    return browser

driver=setUpClass()